<template>
  <div class="content">
    <!-- 顶部标题 -->
    <van-nav-bar title="个人中心" right-text="设置" left-arrow @click-left="onClickLeft" @click-right="onClickRight"/>
    <!-- 优惠券 -->
    <van-collapse v-model="activeNames">
      <van-collapse-item title="收货地址" name="1">
        <div>收货地址1</div>
        <div>收货地址2</div>
        <div>收货地址3</div>
      </van-collapse-item>
      <van-collapse-item title="个人信息2" name="2">
        个人信息2
      </van-collapse-item>
      <van-collapse-item title="个人信息3" name="3" >
        个人信息3
      </van-collapse-item>
    </van-collapse>
  </div>
</template>

<script>
export default {
  data () {
    return {
      activeNames: ['1'],
      username: ''
    }
  },
  mounted () {
    // 判断用户是否登录，如果没有登录，返回到Home
    if (!this.username) {
      this.$router.push({path: 'Login'})
    }
  },
  methods: {
    onClickLeft () {
      window.history.go(-1)
    },
    onClickRight () {
      // this.$router.push({name: 'Settlement', params:{ totalPrice: this.totalPrice}});
      if (this.username) {
        this.$router.push({name: 'UserCenter', params: {username: this.username}})
      } else {
        this.$router.push({path: 'Login'})
      }
    }
  }
}
</script>

<style scoped>

</style>
